						;*********************************************************
						;* PIC 12F675 On Delay timer
						;*********************************************************

;***********************************************************************************************************
; This is for delaying application of HV  on a  linear amp 						   *
;***********************************************************************************************************

;********************************************************************************************************************
; An internal oscillator is used. GP0 is the output (Pin 7) There is a connection to a 1 Kohm to a  LED to ground
; and to the base of the 2N3904. The emitter is grounded and the collector is connected to one end of
; the reed realy and the other end is connected to 12 volts (a 5 volt relay would only require a single supply). 
; There is a 1N914 connected across the relay coil --cathode goes to the supply and the anode to the collector. 
; The LED gives a visual indication of a time out.  Not elegant but it works!
;*********************************************************************************************************************	

			List p=12f675
			Include "p12f675.inc"
		  	__CONFIG 0X3F94				;Internal oscillator no clock out


COUNT1	EQU	0x20
COUNT2	EQU	0x21
COUNT3	EQU 0x22


		ORG	 0x000			;Start program memory location
		GOTO MAIN
		ORG	 0x004			;Reset Vector
		GOTO MAIN
;*******************************20.01 Seconds*************************************************************************
SEC20

		MOVLW	0x83		; Basic 20 seond timer
		MOVWF	COUNT1
L1		MOVLW	0xe0
		MOVWF	COUNT2
L2		MOVLW	0xe2
		MOVWF	COUNT3
L3		DECFSZ	COUNT3,1
		GOTO	L3
		DECFSZ	COUNT2,1
		GOTO	L2
		DECFSZ	COUNT1,1
		GOTO	L1
		MOVLW	0x01
		MOVWF	COUNT1
LP98	DECFSZ	COUNT1,1
		GOTO	LP98
		NOP
		NOP
		NOP
		NOP
		RETLW	0
;***********************************180 Second timer*****************
SEC180					;This takes a 9X the 20 second timer = 180 seconds (3 minute delay)

		CALL	SEC20
		CALL	SEC20
		CALL	SEC20
		CALL	SEC20
		CALL	SEC20
		CALL	SEC20
		CALL	SEC20
		CALL	SEC20
		CALL	SEC20
		RETURN

;***************************************************************************************************
MAIN
		CALL	0x3FF				; Call up internal calibration
		BSF		STATUS,RP0		    ; hange to Bank 1
		MOVWF	OSCCAL				; set up for RC oscillator
		CLRF	GPIO			    ; Initiate GPIO
		MOVLW	001h				; Set  GPIO <0> to Digital I/O  others not used
		MOVWF	CMCON			    ; Turn Off Comparator
		CLRF	ANSEL			    ; Turn off Analog Select
		
		MOVWF	TRISIO			    ; GP <0> is the output GP0 = Pin #7
		BCF		STATUS,RP0		    ; Change back to Bank 0
		BCF		GPIO,GP0			; Clears the output so no output at turn on
	
		
		
;***************************************************************************************



		BSF		GPIO,GP0		
		CALL	SEC180							
		BCF		GPIO,GP0

LOOP1   CALL	SEC180			;Keeps the timer "on" until the next power cycle
		GOTO 	LOOP1
	
		SLEEP
;***************Actual time 180.11 Seconds--Close enough*****************

		End
